home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / entryy.act < prev    next >
Text File  |  1995-04-22  |  3KB  |  167 lines

  1. ;************************************
  2. ;*                                  *
  3. ;*(C)Copyright 1986 by Paul B. Loux *
  4. ;*                                  *
  5. ;* These routines are in the public *
  6. ;* domain,  and  are not to be sold *
  7. ;* for a profit. They may be freely *
  8. ;* distributed, provided  that this *
  9. ;* header remains in place. Use and *
  10. ;* enjoy! PBL, CIS 72337,2073.      *
  11. ;*                                  *
  12. ;************************************
  13. ;
  14. ;     File ENTRYYN.ACT
  15. ;
  16. ;     BYTE FUNC EntryYN()
  17. ;
  18. ;     Returns  either  one or zero
  19. ;     (true/false), representing a
  20. ;     one-character (Y or N)  user
  21. ;     response to yes/no questions
  22. ;     (uses EntryS(),the universal
  23. ;     string entry utility, to get
  24. ;     the keystroke).   
  25. ;
  26. ;     The routine supports typical
  27. ;     EntryS() features, including
  28. ;     screen  coordinates supplied
  29. ;     by the calling routine; pass
  30. ;     through  of error codes, for
  31. ;     ESC and Ctrl-Z handling; and
  32. ;     timeouts. This  routine also
  33. ;     allows a default value for a
  34. ;     null-response (if desired).
  35. ;
  36. ;  Parameters:
  37. ;
  38. ;     col=screen echo horiz column
  39. ;     row=screen echo vert column
  40. ;
  41. ;     default= 0 for null="N"
  42. ;              1 for null="Y"
  43. ;              2 to disallow null
  44. ;
  45. ;     err_ptr= pointer to pass err
  46. ;              to calling routine.
  47. ;
  48. ;************************************
  49. ;          
  50.    INCLUDE "ENTRYS.ACT"
  51. ;          
  52. ;************************************
  53. ;          
  54. ;
  55. BYTE FUNC Ask_YN(BYTE col,row,default
  56.                 BYTE POINTER err_ptr)
  57.  
  58. DEFINE max  ="1",
  59.        typec="7",
  60.        xit  ="0"
  61.  
  62. BYTE response,min       
  63. BYTE ARRAY field="x"
  64.  
  65. IF default=2 THEN 
  66.  min=1
  67. ELSE
  68.  min=0
  69. FI
  70.  
  71. DO
  72.  
  73. ENTRYS(field,min,max,typec,xit,    
  74.        col,row,err_ptr)
  75.  
  76. IF err_ptr^#0 THEN RETURN(0) FI
  77.  
  78. IF field(0)=0 THEN       ; null entry
  79.   IF default=0 THEN
  80.     PUT('N)
  81.   ELSE
  82.     PUT('Y)
  83.   FI
  84.   RETURN(default)
  85. FI
  86.  
  87. response=field(1)
  88.  
  89. IF response=89 THEN      ; 'Y
  90.  RETURN(1)
  91. ELSEIF response=78 THEN  ; 'N
  92.  RETURN(0)
  93. FI
  94.  
  95. OD
  96.  
  97. RETURN(0)
  98. ;
  99. ;
  100. ;************************************
  101. ;
  102. ; Example of usage:
  103.  
  104. PROC Test8()
  105.  
  106. BYTE answer
  107. BYTE x,y,default
  108. BYTE errcde
  109. BYTE POINTER err_ptr
  110.  
  111. errcde=0
  112. err_ptr=@errcde
  113.  
  114. x=33  y=5
  115. default=0
  116.  
  117. PUT(125)
  118. POSITION(1,5)
  119. PRINT("Do you own a computer (Y/[N]): ")
  120. answer=Ask_YN(x,y,default,err_ptr)
  121. POSITION(1,7)
  122.  
  123. IF answer THEN
  124.   x=26  y=7
  125.   default=1
  126.   PRINT("Is it an Atari ([Y]/N): ")
  127.   answer=Ask_YN(x,y,default,err_ptr)
  128.   POSITION(1,9)
  129.  
  130.   IF answer THEN
  131.     x=17 y=9
  132.     default=2
  133.     PRINT("Is it an 8-bit?     (Y/N)")
  134.     answer=Ask_YN(x,y,default,err_ptr)
  135.     POSITION(1,11)
  136.  
  137.     IF answer THEN
  138.       PRINT("Congratulations.")      
  139.     ELSE
  140.       x=9  y=11
  141.       default=0
  142.       PRINT("520 ST?   (Y/[N])")
  143.       answer=Ask_YN(x,y,default,err_ptr)
  144.       POSITION(1,13)
  145.  
  146.       IF answer THEN 
  147.         PRINT("Congratulations.")
  148.       ELSE
  149.         PRINTE("Must be a 1040 ST then.")
  150.       FI
  151.     FI
  152.   ELSE
  153.     PRINTE("Too bad.")
  154.   FI
  155.  
  156. ElSE
  157.   x=32  y=7
  158.   default=1
  159.  
  160.   POSITION(1,7)
  161.   PRINTE("Too bad.")
  162. FI 
  163.  
  164. RETURN
  165.  
  166.  
  167.